<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 用户管理页面 -->
<section data-v-c2f0218a="" class="main-content userManage view">
				<div class="search_user">
					<input  class="search_name" placeholder="请输入用户名" maxlength="20" type="text" value=""/>
					<select class="search_grade">
						 <option value="0">代理等级</option>
						 <option value="1">一级代理</option>
					     <option value="2">二级代理</option>
					     <option value="3">三级代理</option>
					     <option value="4">四级代理</option>
					     <option value="5">五级代理</option>
					</select>
					<button class='shosuo'>搜索</button>
				</div>
				
					<table data-v-16d172c6="" class="class-table-needClick  class-tableDataTable  display table table-striped table-bordered table-hover"  id="table-i-daili" ><!-- table  -->
						<thead data-v-16d172c6="">
							<tr data-v-16d172c6="">
							<th data-v-30e14d66="" class="hidden-td">会员账号</th>
							<th data-v-30e14d66="">会员账号</th>
							<th data-v-30e14d66="">代理等级</th>
							<th data-v-30e14d66="">返点金额</th>
							<th data-v-30e14d66="">团队人数</th>
							<th data-v-30e14d66="">团队余额</th>
							<th data-v-30e14d66="">个人余额</th>
							<th data-v-30e14d66="">个人充值</th>
							<th data-v-30e14d66="">个人提款</th>
							<th data-v-30e14d66="">个人投注</th>
							</tr>
						</thead>
						<tbody  id="div-user-message">
							<td>没有更多的数据了</td>
						</tbody>
					</table>
			</section>
<script type="text/javascript">
var user_id;
function dataTable03() {
	var oTable = $("#table-i-daili").DataTable({
		"bProcessing": false, // 是否显示取数据时的那个等待提示
		"bServerSide": true, //这个用来指明是通过服务端来取数据
		"bPaginate": true, //是否显示分页 
		"sAjaxSource": "/agent/findOneAgent.do", //这个是请求的地址
		"fnServerData": retrieveData, // 获取数据的处理函数
		"destroy": true,
		// "bPaginate": true,
		"bLengthChange": true,
		"bSort": false,
		// "bInfo": true,
		"bAutoWidth": false,
		"bServerSide": true,
		'aLengthMenu': [10],
		"searching": false,
		"pagingType": "simple_numbers",
		"dom": "t<'tableinfo'i<'tableSearch'p>l>",
		"language": { //语言设置  
			/* " lengthMenu": "每页显示 _MENU_ 条记录", */
			"zeroRecords": "没有检索到数据",
			"sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
			"info": "没有数据",
			"oPaginate": {
				"sFirst": "首页",
				"sPrevious": "前一页",
				"sNext": "后一页",
				"sLast": "尾页"
			},
			"search": "",
			"searchPlaceholder": "请输入关键字",
			"infoFiltered": "(从  _MAX_ 记录中搜索出结果)",
			"infoEmpty": "没有找到匹配的信息",
		},
		"columnDefs": [{
			"defaultContent": "",
			"targets": "_all"
		}],
		"columns": [{
				"data": "user_id",
				"className": "hidden-td user_id-td"
			},
			{
				"data": "user_name",
				"className": "user_name-td"
			},
			{
				"data": "agent_grade",
				"className": "agent_grade-td"
			},
			{
				"data": "rebate_money",
				"className": "rebate_money-td"
			},
			{
				"data": "state",
				"className": "state-td"
			},
			{
				"data": "balance",
				"className": "balance-td"
			},
			{
				"data": "one_money",
				"className": "one_money-td"
			},
			{
				"data": "one_recharge",
				"className": "one_recharge-td"
			},
			{
				"data": "one_drawing",
				"className": "one_drawing-td"
			},
			{
				"data": "one_betting",
				"className": "one_betting-td"
			},
		],
	})

	function retrieveData(sSource, aoData, fnCallback) {
		$.ajax({
			url: sSource, //这个就是请求地址对应sAjaxSource
			data: {
				"pageCount": aoData[0].value,
				"startIndex": aoData[3].value,
				"lineCount": aoData[4].value,
			}, //这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
			type: 'post',
			dataType: 'json',
			async: false,

			success: function(result) {
				var newData = result.aaData;
				if(newData.length == 0) {}
				for(i = 0; i < newData.length; i++) {
					item = newData[i];
					user_id = item.user_id;
					item.agent_grade = item.agent_grade + "级代理"
				}
				fnCallback(result); //把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
			},
			error: function(msg) {}
		});
	}
}
dataTable03()
 $(".shosuo").on("click",function(){
	 console.log($(".search_user").find(".search_name").val())
	 if($(".search_user").find("input").val()=="" && $(".search_user").find("select").val()=="" ){
			return;
		}else{  
		$.ajax({
			type:"post",
			url:"/agent/findAgentInfo.do",
			data:{
				"name":$(".search_user").find(".search_name").val(),
				"grade":$(".search_grade").val(),
			},
			success:function(data){
				var newData = data.data;
				$("#div-user-message").empty()
				if(newData == "") {
					$("#table-i-daili_paginate").hide();
					var html = "<tr class='odd'><td valign='top' colspan='9' class='dataTables_empty'>暂时没有数据哦</td></tr>"
					$("#div-user-message").append(html);
				} else {
					$("#table-i-daili_paginate").show();
					var tduirs
					if(newData[0].state <= 0) {
						tduirs = 1;
					} else {
						tduirs = newData[0].state
					}
					var yue
					if(newData[0].balance <= 0) {
						yue = 0
					} else {
						yue = newData[0].balance
					}
					var html =
						"<tr role='row' class='odd'>" +
						"<td class='user_name-td' style='width:88px' >" + newData[0].user_name + "</td>" +
						"<td class='agent_grade-td' style='width:88px' >" + newData[0].agent_grade + "级代理</td>" +
						"<td class='rebate_money-td' style='width:88px'>" + newData[0].rebate_money + "</td>" +
						"<td class='one_money-td' style='width:88px'>" + tduirs + "</td>" +
						"<td class='one_money-td' style='width:88px'>" + yue + "</td>" +
						"<td class='one_money-td' style='width:88px'>" + newData[0].one_money + "</td>" +
						"<td class='one_recharge-td' style='width:88px'>" + newData[0].one_recharge + "</td>" +
						"<td class='one_drawing-td' style='width:88px'>" + newData[0].one_drawing + "</td>" +
						"<td class='one_betting-td' style='width:88px'>" + newData[0].one_betting + "</td>" +
						"</tr>"
					$("#div-user-message").append(html); 
				} 
			}
		}) 
	} 
}) 	
</script>
